/*
	自定义函数实现数组元素从大到小排列
*/
#include <stdio.h>
//自定义一个函数用于指定从大到小的规则
int rule(int num1,int num2){
		return num1 < num2;
	}
int rule2(int num1,int num2){
		return num1 > num2;
	}
void maxArr(int* arr,int len,int (*pRule)(int num1,int num2)){
		int i = 0,j = 0;
		for(i = 0;i < len - 1;i++){
			for(j = i + 1;j < len;j++){
					//if(arr[i] < arr[j]){
					if(pRule(arr[i],arr[j])){
						int temp = arr[i];
						arr[i] = arr [j];
						arr[j] = temp;
						}
				}
			}
	}

int main(void){
	int arr[10] = {1,2,3,4,5,6,7,8,9,0};
	//maxArr(arr,10,rule);
	maxArr(arr,10,rule2);
	int i = 0;
	for(i = 0;i < 10;i++){
				printf("arr[%d] = %d\n",i,arr[i]);
			}
	}
